/*
 * Source.java
 *
 * Created on August 2, 2004, 1:17 PM
 */

package org.infoset.xml.util;

import java.net.URI;
import org.infoset.xml.*;
/**
 *
 * @author  R. Alexander Milowski
 */
public class Source {
   
   /** Creates a new instance of Source */
   private Source() {
   }
   
   public static String formatLocation(SourceLocation l) {
      return formatLocation(l.getSourceURI(),l.getLine(),l.getColumn());
   }
   
   public static String formatLocation(URI source,int line,int column) {
      return source==null ? line+":"+column : source.toString()+':'+line+":"+column;
   }
   
   public static String formatLocation(Item i) {
      if (i==null) {
         return null;
      }
      if (i instanceof Location) {
         Location l = (Location)i;
         URI base = ItemProperties.findBaseURI(i);
         return formatLocation(base,l.getLine(),l.getColumn());
      } else {
         return null;
      }
   }
   
}
